﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;

namespace CsharpTool.SignalRServer
{
    /// <summary>
    /// ISignalRHub
    /// </summary>
    public interface ISignalRHub<TClient, TReceiveData> where TClient : class, ISignalRHubClient
    {
        Task OnConnectedAsync();

        Task OnDisconnectedAsync(Exception exception);

        /// <summary>
        /// 客户端发送消息时调用
        /// </summary>
        [HubMethodName("SendMsg")]
        Task SendMsgAsync(TReceiveData msg);
    }

    /// <summary>
    /// SignalRHubClient客户端接口
    /// </summary>
    public interface ISignalRHubClient
    {
        /// <summary>
        /// 客户端接收消息，事件绑定方法
        /// </summary>
        [HubMethodName("ReceiveMsg")]
        Task ReceiveMsgAsync(object? msg);
    }
}
